/*
 * Copyright 2007 - The JDPF Project Team (http://www.jdpf.org) 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.jdpf.booter;


import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

/**Class used to store locally and to have a way to access the context of the 
 * System Bundle.
 * <p>This class is loaded by the OSGi framework at startup. It only stores the 
 * bundle context of the System Bundle and makes it accessible to the 
 * application to install all the other bundle it needs to run properly.</p>
 * 
 * @author <a href="mailto:farina.bruno@gmail.com">Bruno Farina</a>
 */
public class ApplicationActivator implements BundleActivator {
	
	
	private BundleContext context;

	/**
	 * @see org.osgi.framework.BundleActivator#start 
	 * 										(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		System.out.println("start(BundleContext) - Bundle "
					+ this.getClass().getCanonicalName() + " started");
		this.context=context;
	}

	/**
	 * @see org.osgi.framework.BundleActivator#stop 
	 * 										(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		this.context=null;
		System.out.println("stop(BundleContext) - Bundle "
				+ this.getClass().getCanonicalName() + " stopped");
	}
	
	/**This method is used to get the bundle context of the System Bundle
	 * @return The bundle context of the System Bundle
	 */
	public BundleContext getContext(){
		return this.context;
	}

}
